Skip to content

Update image handling #14564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jaffrepaul
Copy link
Contributor

DESCRIBE YOUR PR

This PR implements a modern image lightbox for all documentation images, enhancing the user experience.

Previously, clicking an image would open the raw image file in a new browser tab. This change introduces an in-page modal overlay for images, leveraging Radix UI Dialog for accessibility and a smooth user experience.

Key features:

  • Images now open in a responsive lightbox overlay on click.
  • Preserves existing functionality: right-click or Ctrl/Cmd+click still opens the image in a new tab.
  • Includes accessibility features (keyboard navigation, ARIA labels).
  • Adds subtle CSS animations for opening/closing the lightbox.

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

LEGAL BOILERPLATE

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

EXTRA RESOURCES

  • [Sentry Doc

Copy link

vercel bot commented Aug 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
develop-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 9, 2025 2:07am
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 9, 2025 2:07am

Copy link

codecov bot commented Aug 5, 2025

Bundle Report

Changes will increase total bundle size by 91.16kB (0.4%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-client-array-push 9.9MB 47.32kB (0.48%) ⬆️
sentry-docs-server-cjs 12.4MB 43.84kB (0.35%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 882.71kB -0.0%
static/css/*.css 192 bytes 12.9kB 1.51%
static/css/*.css -928 bytes 961 bytes -49.13%
static/css/*.css -1 bytes 1.89kB -0.05%
static/css/*.css 1.3kB 746.03kB 0.17%
static/css/*.css -1.28kB 12.71kB -9.12%
static/css/*.css 6.51kB 11.69kB 125.92% ⚠️
static/css/*.css -14.26kB 4.84kB -74.64%
static/css/*.css (New) 11.0kB 11.0kB 100.0% 🚀
static/chunks/8321-*.js -3 bytes 425.87kB -0.0%
static/chunks/8423-*.js (New) 284.92kB 284.92kB 100.0% 🚀
static/chunks/2408-*.js 5.33kB 283.72kB 1.92%
server/app/api/ip-*.js 737 bytes 263.38kB 0.28%
server/app/_not-*.js 737 bytes 263.37kB 0.28%
server/app/[[...path]]/page_client-*.js 737 bytes 263.33kB 0.28%
server/app/platform-*.js 796 bytes 248.17kB 0.32%
static/chunks/app/[[...path]]/page-*.js 3.81kB 87.96kB 4.52%
static/chunks/app/platform-*.js 5 bytes 13.22kB 0.04%
static/chunks/webpack-*.js 10 bytes 5.33kB 0.19%
app-*.json 82 bytes 4.68kB 1.78%
static/OUxI4c7JoJBvvHsK6For2/_buildManifest.js (New) 684 bytes 684 bytes 100.0% 🚀
static/OUxI4c7JoJBvvHsK6For2/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/chunks/2009-*.js (Deleted) -252.38kB 0 bytes -100.0% 🗑️
static/W84V3ihBRYEI689c0Du_w/_buildManifest.js (Deleted) -684 bytes 0 bytes -100.0% 🗑️
static/W84V3ihBRYEI689c0Du_w/_ssgManifest.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️

Files in static/chunks/app/[[...path]]/page-*.js:

  • ./src/components/lightbox/lightbox.module.scss → Total Size: 387 bytes
view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js 5.66kB 1.78MB 0.32%
../instrumentation.js 32 bytes 1.1MB 0.0%
9523.js 32 bytes 1.08MB 0.0%
../app/[[...path]]/page.js.nft.json 715 bytes 739.39kB 0.1%
../app/platform-redirect/page.js.nft.json 715 bytes 739.3kB 0.1%
../app/sitemap.xml/route.js.nft.json 715 bytes 736.78kB 0.1%
../app/[[...path]]/page.js 35.95kB 603.39kB 6.34% ⚠️
2311.js (New) 29.86kB 29.86kB 100.0% 🚀
9567.js 24 bytes 20.67kB 0.12%
7269.js (Deleted) -29.86kB 0 bytes -100.0% 🗑️

Files in ../app/[[...path]]/page.js:

  • ./src/components/lightbox/lightbox.module.scss → Total Size: 378 bytes

  • ./src/components/imageLightbox/index.tsx → Total Size: 475 bytes

Files in 2311.js:

  • ./app/globals.css → Total Size: 1 bytes

Files in 9567.js:

  • ./src/remark-image-size.js → Total Size: 1.06kB

App Routes Affected:

App Route Size Change Total Size Change (%)
/ -1 bytes 2.62MB -0.0%
/[[...path]] 35.95kB 3.16MB 1.15%

@jaffrepaul jaffrepaul changed the title Analyze image display and repository architecture Update image handling Aug 5, 2025
cursor[bot]

This comment was marked as outdated.

@jaffrepaul jaffrepaul requested a review from coolguyzone August 6, 2025 17:26
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@sergical sergical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 🤖 is almost there! 😅

Comment on lines 172 to 200
{shouldUseNextImage && dimensions ? (
<Image
src={getImageUrl(src, imgPath)}
alt={alt}
width={dimensions.width}
height={dimensions.height}
className="max-h-[90vh] max-w-[90vw] object-contain"
style={{
width: 'auto',
height: 'auto',
}}
priority
{...imageCompatibleProps}
/>
) : (
/* eslint-disable-next-line @next/next/no-img-element */
<img
src={getImageUrl(src, imgPath)}
alt={alt}
loading="lazy"
decoding="async"
className="max-h-[90vh] max-w-[90vw] object-contain"
style={{
width: 'auto',
height: 'auto',
}}
{...props}
/>
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pass a isInline boolean to renderImage and then add classNAme if not? otherwise it's very similar to the function above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

};

return (
<Dialog.Root open={open} onOpenChange={setOpen}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still abstract Dialog or call it Lightbox as it's own reusable component similar to ShadCN https://ui.shadcn.com/docs/components/dialog to consume in here.

return (
<Dialog.Root open={open} onOpenChange={setOpen}>
{/* Custom trigger that handles modifier keys properly */}
<div
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tried using Dialog.Trigger? I think that would eliminate the need for custom onClick / keydown handling and would do semantics / accessibility for us?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things were getting wonky with the intended behavior and needed some custom event handling but things have changed a bit since then. I'll see if we can't lean on this now

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Comment on lines 125 to 132
<div
onClick={handleModifierClick}
onKeyDown={handleModifierKeyDown}
onClick={handleClick}
onAuxClick={handleClick}
onKeyDown={handleKeyDown}
className="cursor-pointer border-none bg-transparent p-0 block w-full no-underline"
aria-label={`View image: ${alt}`}
role="button"
tabIndex={0}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think it needs this (apart from aira-label) because https://github.com/radix-ui/primitives/blob/main/packages/react/dialog/src/dialog.tsx#L105-L107 handles it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice. Less code is the best code! I still need some of it for the modifier logic but can pull some off

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup and you can put all that on the <Dialog.Trigger /> directly and remove the asChild prop

@jaffrepaul jaffrepaul force-pushed the cursor/analyze-image-display-and-repository-architecture-6c32 branch from 9200f86 to 5dc9bcd Compare August 9, 2025 01:19
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@sergical sergical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Comment on lines +130 to +140
<Lightbox.Root open={open} onOpenChange={setOpen} content={renderImage(false)}>
<Lightbox.Trigger
onClick={handleClick}
onAuxClick={handleClick}
onKeyDown={handleKeyDown}
className="cursor-pointer border-none bg-transparent p-0 block w-full no-underline"
aria-label={`View image: ${alt}`}
>
{renderImage()}
</Lightbox.Trigger>
</Lightbox.Root>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@jaffrepaul jaffrepaul merged commit 7863d47 into master Aug 11, 2025
15 checks passed
@jaffrepaul jaffrepaul deleted the cursor/analyze-image-display-and-repository-architecture-6c32 branch August 11, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants